package com.joy.vo;

import com.joy.model.Assignment;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskDetailVO {

    private Integer id;

    private String State;

    private String TaskName;

    private String StartTime;

    private String EndTime;

    public static TaskDetailVO from(Assignment assignment) {
        TaskDetailVO taskDetailVO = new TaskDetailVO();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        taskDetailVO.setId(assignment.getAssignmentId());
        taskDetailVO.setState("补交中");
        taskDetailVO.setTaskName(assignment.getAssignmentName());
        if (assignment.getStartTime() != null) {
            taskDetailVO.setStartTime(simpleDateFormat.format(assignment.getStartTime()));
        }
        if (assignment.getEndTime() != null) {
            taskDetailVO.setEndTime(simpleDateFormat.format(assignment.getEndTime()));
        }
        return taskDetailVO;
    }

}
